#!/usr/bin/env python
# -*— coding: utf-8 -*-
import socket, sys

dest = ('<broadcast>', 8080)

s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)

s.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1) # 允许发广播

s.sendto("HI",dest)

print("等待对方回复 。。。")

while True:
  (buf, address) = s.recvfrom(2048)
  print("Received from %s: %s"%(address, buf))